package  com.pcbly.web.business.news;

/**
* @author carl.song
* Copyright (c) 2010 Lightsoft, International.
* All rights reserved.
*
*/

import java.util.HashMap;
import java.util.List;

import com.pcbly.web.persistence.news.NewsTagDao;
import com.pcbly.web.persistence.table.ColumnDao;
import com.pcbly.web.bean.news.NewsTagBean;
import com.pcbly.web.bean.table.ColumnBean;
import com.pcbly.web.business.BaseServiceImp;
import com.pcbly.web.components.hibernate.support.Page;
import com.pcbly.web.components.form.AbstractAnalyseCommonDataExt;
import com.pcbly.web.components.form.AnalyseCommonDataExtCreate;
import com.pcbly.web.components.form.AnalyseCommonDataExtEdit;
import com.pcbly.web.components.form.AnalyseCommonDataExtView;

 
public class NewsTagServiceImp extends BaseServiceImp<NewsTagBean> implements NewsTagService {
	 public NewsTagServiceImp() {
		super();
		// TODO Auto-generated constructor stub
	}
	private NewsTagDao newsTagDao;
	
	private ColumnDao columnDao;

	public void setColumnDao(ColumnDao columnDao) {
		this.columnDao = columnDao;
	}
	
	public void setNewsTagDao(NewsTagDao newsTagDao) {
		this.newsTagDao = newsTagDao;
	}
	
	@Override
	public NewsTagBean getNewsTagBeanById(String id) throws Exception {
		// TODO Auto-generated method stub
		return newsTagDao.get(NewsTagBean.class,id);
	}
	
	@Override
	public void removeNewsTagBeanById(String id) throws Exception{
		newsTagDao.removeNewsTagBeanById(id);
	}
	
	@Override
	public void removeNewsTagBeanByIds(String ids) throws Exception{
		newsTagDao.removeNewsTagBeanByIds(ids);
	}
	
	
	@Override
	public NewsTagBean saveNewsTagBean(NewsTagBean news) throws Exception{
		return newsTagDao.saveNewsTagBean(news);
	}
	
	@Override
	public NewsTagBean updateNewsTagBean(NewsTagBean news) throws Exception{
		newsTagDao.saveObject( news);
		return news;
	}
	public Page<NewsTagBean>  findNewsTagBeanByCond(NewsTagBean bean,
			Page<NewsTagBean> page, String orderByName, boolean asc)
			throws Exception{
		return newsTagDao.findNewsTagBeanByCond(
				bean, page, orderByName, asc);
	}
	
	@Override
	public String findNewsTagBeanExtCreate(String tableName) throws Exception {
		// TODO Auto-generated method stub
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtCreate();
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findNewsTagBeanExtEdit(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = newsTagDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtEdit();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findNewsTagBeanExtView(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = newsTagDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtView();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public void saveNewsTagBeanExt(String sql) throws Exception {
		// TODO Auto-generated method stub
		newsTagDao.saveCommnonDataBeanExt(sql);
	}

	@Override
	public boolean getHasNewsTagBeanExtData(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		return newsTagDao.getHasCommnonDataBeanExt(tableName, id);
	}
}
